package com.example.jack.community.view.me.personinfo;

import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.support.percent.PercentRelativeLayout;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.example.jack.community.R;
import com.example.jack.community.view.me.BlackStatusActivity;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 个人信息页面，点击主页头像进入
 */
public class Per_infoActivity extends BlackStatusActivity {


    List<Uri> mSelected;

    private static final String TAG = "TonJie";

    //图片返回
    @BindView(R.id.img_back)
    ImageView imgBack;

    //文字返回
    @BindView(R.id.txt_back)
    TextView txtBack;

    //用户头像
    @BindView(R.id.user_logo)
    ImageView userLogo;

    //用户头像布局
    @BindView(R.id.per_userlogo)
    PercentRelativeLayout perUserlogo;

    //用户个性签名布局
    @BindView(R.id.per_signature)
    PercentRelativeLayout perSignature;

    //我的二维码布局
    @BindView(R.id.per_mycode)
    PercentRelativeLayout perMycode;

    //更多个人信息布局
    @BindView(R.id.per_personinfo)
    PercentRelativeLayout perPersoninfo;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.me_per_info);
        ButterKnife.bind(this);
        SharedPreferences sharedPreferences = getSharedPreferences("data", MODE_PRIVATE);
        String user_logo = sharedPreferences.getString("user_logo", "0");

        if (user_logo.equals("0")) {
            Glide.with(this).load(R.drawable.login_users).
                    into(userLogo);
            Log.d(TAG, "onCreateView: 等于0");
        } else {
            Glide.with(this).load(user_logo).
                    into(userLogo);

        }
    }



    @Override
    protected void onRestart() {
        super.onRestart();
        SharedPreferences sharedPreferences = getSharedPreferences("data", MODE_PRIVATE);
        String user_logo = sharedPreferences.getString("user_logo", "0");

        if (!user_logo.equals(0)) {
            Glide.with(this).load(user_logo).into(userLogo);
        }
    }


    @OnClick({R.id.img_back, R.id.txt_back, R.id.per_userlogo, R.id.per_signature, R.id.per_mycode, R.id.per_personinfo, R.id.activity_person_info})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.img_back:
                finish();
                break;
            case R.id.txt_back:
                finish();
                break;
            case R.id.per_userlogo:
                startActivity(new Intent(Per_infoActivity.this, My_LogoActivity.class));
                break;
            case R.id.per_signature:
                startActivity(new Intent(Per_infoActivity.this, MysignatureActivity.class));
                break;
            case R.id.per_mycode:
                startActivity(new Intent(Per_infoActivity.this, MyCodeActivity.class));
                break;
            case R.id.per_personinfo:
                startActivity(new Intent(Per_infoActivity.this, Perfect_Per_info_aActivity.class));
                break;
            case R.id.activity_person_info:
                break;
        }
    }
}
